﻿using SqlSugar;
using System.Data;
using Microsoft.Data.SqlClient;
using MySql.Data.MySqlClient;

namespace Inventorycount.API.Read.Extensions
{
    public static class ProduceExtensions
    {
        
        public static IServiceCollection DapperHeaper(this IServiceCollection services, WebApplicationBuilder builder)
        {
            // 正确方式：通过已存在的配置获取连接字符串
            services.AddScoped<IDbConnection>(provider =>
            {

                var connection = new MySqlConnection(builder.Configuration.GetConnectionString("str"));
                connection.Open();
                return connection;


            });
            return services;
        }
    }
}
